<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/general.xhtml">

	<ui:define name="title">
		<h:outputText value="Add New Results" />
	</ui:define>

	<ui:define name="content">
		<h:form enctype="multipart/form-data" id="form">
		
			<p:tabMenu activeIndex="0">
		        <p:menuitem value="Add New Results" url="new"/> 
		        <p:menuitem value="Edit Static Data" url="edit"/>  
	        </p:tabMenu>
	       
			
			<p:fileUpload mode="advanced"
				fileUploadListener="#{file.addFile}"
				allowTypes="/(\.|\/)(csv|CSV)$/"
				auto="true"
				update="files, messages, filesPanel"
				label="Browse"
			/>
			
			<p:outputPanel id="filesPanel">	
				<p:panel id="filesPanel1" rendered="#{file.render}">
					<p:dataTable id="files" var="uFile" value="#{file.uploadedFiles}">
		
				        <p:column headerText="Name">
				            <h:outputText value="#{uFile.file.name}" />
				        </p:column>
				        
				        <p:column headerText="Status" style="width: 50%; text-align: center;">
				        	<h:outputText value="#{uFile.status}" />
				        </p:column>
		
				        <p:column style="width:4%">
				                <p:commandButton id="selectButton" update=":form:filesPanel" icon="ui-icon-close" title="Remove" actionListener="#{file.deleteFile(uFile)}" />
				        </p:column>
		
		    		</p:dataTable> 
		    		
		    		<p:poll widgetVar="refresher" id="refresher" interval="1" update="filesPanel" autoStart="false" listener="#{file.start}" />
		    		<p:commandButton id="start" value="Start" title="Start Parsing" style="position: relavite; left: 80%;" actionListener="#{file.start}" update="filesPanel" />
		    		<p:commandButton id="close" value="Close" update="messages, filesPanel" actionListener="#{file.close}" style="position: relavite; left: 80%" />
		    	</p:panel>
	    	</p:outputPanel>
	        
				<p:messages id="messages" showDetail="false" autoUpdate="true" /> 
		</h:form>
		


	</ui:define>

</ui:composition>